package com.example.lixinwei

import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.ListView
import androidx.appcompat.app.AppCompatActivity
import com.example.xiesiyu.R

class HistoryActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_history)

        val historyListView: ListView = findViewById(R.id.historyListView)
        val history = intent.getStringArrayListExtra("history") // 获取传递过来的历史记录

        if (history != null && history.isNotEmpty()) {
            // 使用 ArrayAdapter 将历史记录加载到 ListView
            val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, history)
            historyListView.adapter = adapter
        } else {
            // 如果没有历史记录，显示提示文本
            val noHistoryMessage = listOf("没有历史记录")
            val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, noHistoryMessage)
            historyListView.adapter = adapter
        }
    }
}
